<template>
  <div id="mine-code">
    <section class="content">
      <div class="top">
        <div class="top-content">
          <img
            v-if="avatar !== 'null'"
            :src="avatar"
            alt="">
          <img
            src="../../assets/images/mine/icon-avatar.png"
            v-else
            alt="">
          <div>
            <p>{{ userName }}</p>
            <p>推荐人</p>
          </div>
        </div>
      </div>
      <div class="bottom">
        <p>欢迎加入<span>桂泰惠安</span> !!<br>
          扫码即可加入</p>
        <img :src="codeSrc" alt="">
      </div>
    </section>
  </div>
</template>

<script>
  export default {
    name: "mine-code",
    data() {
      return {
        avatar: localStorage.getItem('avatar'),
        userName: localStorage.getItem('user_login'),
        codeSrc: localStorage.getItem('qrcode_url')
      }
    }
  }
</script>

<style scoped lang="scss">

  #mine-code {

    $code-img-side: 18.8rem;

    position: fixed;
    width: $size-as-parent;
    height: $size-as-parent;
    background: url("../../assets/images/mine/invite-background.png") no-repeat center / $size-as-parent $size-as-parent;

    >.content {
      position: absolute;
      width: 25.5rem;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);

      >.top {
        display: flex;
        justify-content: space-around;
        align-items: center;
        height: 8.8rem;
        margin-bottom: .8rem;
        border-radius: 1.6rem;
        background: rgba(255, 255, 255, .8);

        >.top-content {
          display: flex;
          align-items: center;

          >img {
            width: 5.2rem;
            height: 5.2rem;
            margin-right: 2rem;
            border-radius: 50%;
          }

          >div {
            display: flex;
            flex-direction: column;
            justify-content: space-around;
            height: 3.8rem;

            >p:first-of-type {
              font-size: 1.5rem;
              color: #333;
            }

            >p:last-of-type {
              font-size: 1.2rem;
              color: #999;
            }
          }
        }
      }

      >.bottom {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: center;
        height: 30rem;
        padding: 3.2rem 0 2rem;
        border-radius: 1.6rem;
        background: rgba(255, 255, 255, .8);

        >p {
          font-size: 1.8rem;
          font-weight: bold;
          color: #333;
          text-align: center;

          >span {
            color: #0196ff;
          }
        }

        >img {
          width: $code-img-side;
          height: $code-img-side;
        }
      }
    }
  }
</style>
